package com.lsh.oms.core.enums;

import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 * Exception Order Status
 * Created by panxudong on 16/9/3.
 */
public enum ExceptionOrderStatus {

    NOT_SHIP(1, 12*3600*1000L),
    NOT_RECEIPT(2, 20*3600*1000L),
    NOT_PAY(3, 18*3600*1000L + 24*3600*1000L),
    LIKE_WHOLE_SALE(4, -1L);

    private final Integer status;

    private final Long timeInterval;

    ExceptionOrderStatus(Integer status, Long timeInterval) {
        this.status = status;
        this.timeInterval = timeInterval;
    }

    public Integer getStatus() {
        return status;
    }

    public Integer getTimeInterval() {
        Long nowTime = System.currentTimeMillis();
        Long exceptionTime = nowTime - timeInterval;

        Date date = new Date(exceptionTime);
//        Integer targetTime = (int)TimeUnit.MILLISECONDS.toSeconds(date.getTime());
//        return targetTime;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        Date targetDate = calendar.getTime();
        Integer targetTime = (int)TimeUnit.MILLISECONDS.toSeconds(targetDate.getTime());

        return targetTime;
    }

}
